import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        //2012 12 31
        //366
        String data = scanner.nextLine();

        String year_s = data.substring(0, 4);
        int year = 0;
        for (int i = 0; i < 4; i++) {
            year += (year_s.charAt(i) - '0') * Math.pow(10, 3 - i);
        }
        StringBuilder month_s = new StringBuilder();
        int j = 5;
        char ch = data.charAt(j);
        while (ch != ' ') {
            month_s.append(ch);
            j++;
            ch = data.charAt(j);
        }
        int month = 0;
        if (month_s.length() == 2) {
            for (int i = 0; i < 2; i++) {
                month += (month_s.charAt(i) - '0') * Math.pow(10, 1 - i);
            }
        } else {
            month += month_s.charAt(0) - '0';
        }
        StringBuilder day_s = new StringBuilder();
        j++;
        ch = data.charAt(j);
        while (ch != ' ') {
            day_s.append(ch);
            j++;
            if (j < data.length()) {
                ch = data.charAt(j);
            } else {
                break;
            }
        }
        int day = 0;
        if (day_s.length() == 2) {
            for (int i = 0; i < 2; i++) {
                day += (day_s.charAt(i) - '0') * Math.pow(10, 1 - i);
            }
        } else {
            day += day_s.charAt(0) - '0';
        }

        boolean flag = false;
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            flag = true;
        }

        int count = 0;

        switch (month) {
            case 12:
                count += 30;
            case 11:
                count += 31;
            case 10:
                count += 30;
            case 9:
                count += 31;
            case 8:
                count += 31;
            case 7:
                count += 30;
            case 6:
                count += 31;
            case 5:
                count += 30;
            case 4:
                count += 31;
            case 3:
                count += 28;
            case 2:
                count += 31;
                break;
        }
        count += day;
        if (flag && month > 2) {
            count++;
        }
        System.out.println(count);
    }
}
